package com.example.student.service.impl;

import com.example.student.domain.Course;
import com.example.student.mapper.CourseMapper;
import com.example.student.service.CourseService;
import com.example.student.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    CourseMapper courseMapper;
    @Override
    public PageBean<Course> queryPage(Map<String, Object> map) {
        PageBean<Course> bean = new PageBean<Course>((Integer) map.get("pageno"), (Integer) map.get("pagesize"));
        System.out.println("bean="+ bean);
        System.out.println("map = " + map);
        System.out.println("data" + courseMapper.queryList(map));

        bean.getStartIndex();
        System.out.println(bean.getStartIndex());
        map.put("startIndex",bean.getStartIndex());

        bean.setDatas(courseMapper.queryList(map));

        Integer totalsize =  courseMapper.queryCount(map);
        bean.setTotalsize(totalsize);

        return bean;
    }

    @Override
    public int addCourse(Course course) {
        int isSuccess =  courseMapper.addCourse(course);
        return isSuccess;
    }

}
